//
//  SSMenuViewController.m
//  list
//
//  Created by sujeking on 2017/8/9.
//  Copyright © 2017年 szw. All rights reserved.
//

#import "SSMenuViewController.h"



typedef NS_ENUM(NSUInteger, SSAlignment) {
    SSAlignment_Left,
    SSAlignment_Center,
    SSAlignment_Right,
};

typedef NS_ENUM(NSUInteger, SSFont) {
    SSFont_Add,
    SSFont_minus,
};


static CGFloat minFontSize = 12;
static CGFloat maxFontSize = 20;


@interface SSMenuViewController ()

@property (strong, nonatomic) NSArray *colors;
@property (nonatomic) CGFloat currentFontSize;

@end

@implementation SSMenuViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.currentFontSize =14;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

- (IBAction)alignmentClickAction:(id)sender {
    if (self.delegate) {
        UIButton *btn = (UIButton *)sender;
        NSTextAlignment alignement;
        switch (btn.tag) {
            case SSAlignment_Left:
            {
                alignement = NSTextAlignmentLeft;
            }
                break;
            case SSAlignment_Center:
            {
                alignement = NSTextAlignmentCenter;
            }
                break;
            case SSAlignment_Right:
            {
                alignement = NSTextAlignmentRight;
            }
            default:
                break;
        }
        [self.delegate ss_menuViewcontrollerForAlignment:alignement];
    }
}

- (IBAction)fontSizeClickAction:(id)sender {
    if (self.delegate) {
        UIButton *btn = (UIButton *)sender;
        if (btn.tag == SSFont_Add) {
            if (self.currentFontSize >= maxFontSize) {
                self.currentFontSize = maxFontSize;
            } else {
                self.currentFontSize++;
            }
        } else {
            if (self.currentFontSize <= minFontSize) {
                self.currentFontSize = minFontSize;
            } else {
                self.currentFontSize--;
            }
        }
        [self.delegate ss_menuViewcontrollerForUIFont:[UIFont systemFontOfSize:self.currentFontSize]];
    }
}

- (IBAction)textColorClickAction:(id)sender {
    if (self.delegate) {
        UIButton *btn = (UIButton *)sender;
        [self.delegate ss_menuViewcontrollerForTextColor:self.colors[btn.tag]];
    }
}

// MARK: - GET

- (NSArray *)colors {
    if (!_colors) {
        _colors = @[
                    [UIColor blackColor],
                    [UIColor blueColor],
                    [UIColor brownColor],
                    [UIColor cyanColor],
                    [UIColor greenColor],
                    [UIColor magentaColor],
                    [UIColor orangeColor],
                    [UIColor purpleColor],
                    [UIColor redColor],
                    [UIColor yellowColor],
                    ];
    }
    return _colors;
}

@end
